class Solution
{
public:
    int temperatureTrend(vector<int> &temperatureA, vector<int> &temperatureB)
    {
        int result = 0;
        int sameTrend = 0;
        int n = temperatureA.size();
        for (int i = 1; i < n; ++i)
        {
            int diffA = temperatureA[i] - temperatureA[i - 1];
            int diffB = temperatureB[i] - temperatureB[i - 1];
            if ((diffA == 0 && diffB == 0) || (diffA * diffB > 0))
            {
                ++sameTrend;
            }
            else
            {
                sameTrend = 0;
            }
            result = max(result, sameTrend);
        }
        return result;
    }
};